/*
 * @Date: 2021-09-12 19:21:05
 * @Author: Acckno1
 * @LastEditTime: 2021-09-12 19:22:44
 * @Description: 
 */
#include <iostream>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

int n, e;
float c;
float res[2010];

int main() {
    // 存放 两个多项式的系数和指数
    vector<pair<int, float>> a;
    vector<pair<int, float>> b;
    cin >> n;
    for (int i = 1; i <= n; i ++) {
        cin >> e >> c;
        a.push_back({e, c});
    }
    cin >> n;
    for (int i = 1; i <= n; i ++) {
        cin >> e >> c;
        b.push_back({e, c});
    }
    
    // 一一相乘
    for (auto & x : a) {
        for (auto & y : b) {
            int idx = x.first + y.first;
            float con = x.second * y.second;
            res[idx] += con;
        }
    }
    
    vector<pair<int, float>> c;
    int cnt = 0;
    for (int i = 2009; i >= 0; i -- ) 
        if (res[i] != 0) cnt ++, c.push_back({i, res[i]});
    
    printf("%d", c.size());
    for (auto & r : c) 
        printf(" %d %.1f", r.first, r.second);
    puts("");
    
    return 0;
}